<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    //math不是构造函数，不需要new来调用直接使用即可
     console.log(Math.max(1,2,3,4,5));
     console.log(Math.min(1,2,3,4,5));
     console.log(Math.PI);

    var myMath = {
        PI : 3.1415926,
        max: function(){
            var max = arguments[0];
            for(var i = 1; i<=arguments.length;i++){
                if(arguments[i]>max){
                    max = arguments[i];
                }
            }
            return max;
        },
        min:function(){
            var min = arguments[0];
            for(var i = 1 ;i<=arguments.length;i++){
                if(arguments[i]<min){
                    min = arguments[i];
                }
            }
            return min;
        }
    }
    console.log(myMath.PI);
    console.log(myMath.max(1,5,6,7,9));
    console.log(myMath.min(2,5,9,8,));

    console.log(Math.abs(-1));
    //向下取整
    console.log(Math.floor(0.11));
    //向上取整
    console.log(Math.ceil(1.222));
    //四舍五入
    console.log(Math.round(1.6));
    console.log(Math.round(-1.6));

    //Math对象随机数方法  random() 返回一个随机小数 0 =< x<1
    console.log(Math.random());
    //得到两个数之间的随机数 并且 包含这2个数
    //Math.floor(Math.random() * (max - min + 1)) + min;
     //含最大值，含最小值
     function getRandom(max,min){
         return Math.floor(Math.random() * (max - min + 1)) + min; 
     }
     console.log(getRandom(1,10));
      
      //随机点名
      var arr = ['张三','李四','张三丰','王八'];
      function getRandom1(min,max){
        return Math.floor(Math.random() * (max - min + 1)) + min; 
      }
      console.log(arr[getRandom1(0,arr.length-1)]);
</script>
<body>
    
</body>
</html>